<?php
	include_once 'autoload.php';
	

	session_start();
	
	// if the user is already logged in, go ahead to the albums pages
	$su = HtmlUtil::getSessionUser();
	$ctl = new LoginCtl();
	
	if($su->isLogged()){
		$ctl->redirect('albums.php');
	}

	$ctl->proceed();
	
	$header = new Header();
	$header->render('Login');

	// get the form and proceed with the rendering
	$form = $ctl->getLoginForm();
	
	$lg = $form->getLogin();
	
	$lgencoded = htmlspecialchars($lg);
?>
<form method="post">
<input type="hidden" name="pagename" value="login" id="pgid">
<input type="hidden" name="metname" value="" id="metid">

<h2>Login</h2>
<p>Welcome to picture-album.info</p>
<p>Please enter your credentials, then click "submit"</p>
<table cellpadding="4" cellspacing="0" class="list">
	<tr>
		<td>Login:</td>
		<td><input type="text" name="login" value="<?php  echo $lgencoded; ?>"></td>
	</tr>
	<tr>
		<td>Password:</td>
		<td><input type="password" name="password" value=""></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>
			<input type="button" value="Submit" onclick="triggerform('login')" class="enter">
			<input type="reset" value="Reset">
		</td>
	</tr>
</table>
</form>
<?php
	$footer = new Footer();
	$footer->render();
?>
